package com.cloudsigns.factorymanager2.produce.presenter;

import android.os.Handler;

import com.cloudsigns.factorymanager2.produce.iview.IProductOrderAssignRemoveView;
import com.cloudsigns.factorymanager2.produce.model.IProductOrderAssignRemoveModel;
import com.cloudsigns.factorymanager2.produce.model.ProductOrderAssignRemoveModel;

public class ProductOrderAssignRemovePresenter {
    private IProductOrderAssignRemoveView view;
    private IProductOrderAssignRemoveModel model;
    private Handler handler = new Handler();

    public ProductOrderAssignRemovePresenter(IProductOrderAssignRemoveView view) {
        this.view = view;
        this.model = new ProductOrderAssignRemoveModel();
    }

    public void productOrderAssignRemove() {
        model.productOrderAssignRemoveModel(view.getOrderId(), view.getProductId(), view.getWorkPartId(), view.getWorkPartOrderId(), new ProductOrderAssignRemoveModel.OnProductOrderAssignRemoveListener() {
            @Override
            public void successed() {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getProductOrderAssignRemoveSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getProductOrderAssignRemoveFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });
    }
}
